<!DOCTYPE html>
<html>
{include file="public:header" /}
<body style="padding:10px;">
<table class="layui-table">
    <thead>
    <tr>
        <th style="text-align: center;font-weight: bold">商品ID</th>
        <th style="text-align: center;font-weight: bold">商品标题</th>
        <th style="text-align: center;font-weight: bold">价格</th>
        <th style="text-align: center;font-weight: bold">数量</th>
        <th style="text-align: center;font-weight: bold">总计</th>
        <th colspan="2" style="text-align: center;font-weight: bold">操作</th>
    </tr>
    </thead>
    <tbody>
    {volist name="right" id='right'}
    <tr>
        <td style="text-align: center">{$right.goods_id}</td>
        <td style="text-align: center">{$right.title}</td>
        <td style="text-align: center">
            {if $right.discount <> 0}
            {$right.discount*0.1*$right.price}
            {else/}{$right.price}
            {/if}
        </td>
        <td style="text-align: center">{$right.quantity}</td>
        <td style="text-align: center">{$right.total_money}</td>

        <td style="text-align: center" >
            <button class="layui-btn layui-btn-xs"  onclick="recOrder({$right.id})">恢复订单</button>
        </td>

        <td style="text-align: center" >
            <button class="layui-btn-danger layui-btn-xs"  onclick="delOrder({$right.id})">彻底删除</button>
        </td>

    </tr>

    {/volist}
    </tbody>
</table>

<script>
    function recOrder(id){
        layer.confirm('确定恢复订单号为 '+id+' 的订单吗', {
            icon:3,
            btn: ['确定','取消']
        }, function(){
            $.post('/index.php/user/orderrec',{'id':id},function(res){
                if(res.status==0){
                    layer.alert(res.message,{icon:2});
                }else{
                    layer.msg(res.message);
                    setTimeout(function(){parent.window.location.reload();},1000);
                }
            },'json');
        });
    }
</script>

<script>
    function delOrder(id){
        layer.confirm('确定删除订单号为 '+id+' 的订单吗，该操作不可逆', {
            icon:3,
            btn: ['确定','取消']
        }, function(){
            $.post('/index.php/user/orderDel',{'id':id},function(res){
                if(res.status==0){
                    layer.alert(res.message,{icon:2});
                }else{
                    layer.msg(res.message);
                    setTimeout(function(){parent.window.location.reload();},1000);
                }
            },'json');
        });
    }
</script>


</body>
</html>